<?php 
defined('IN_TS') or die('Access Denied.');

switch($ts){
	
	case "do":
		$userid = aac('user')->isLogin();
		//专辑评论
		$voteid = intval($_POST['voteid']);
		$comment = tsClean($_POST['comment']);	
			
		if($comment==''){
			tsNotice('亲，要写点内容^_^');	
		}else{
			$arrData	= array(
				'voteid'	=> $voteid,
				'userid'	=> $userid,
				'comment'	=> $comment,
				'addtime'=> date('Y-m-d H:i:s'),
			);
		}
		$new['vote']->create('vote_comment',$arrData);

		$count_comment = $new['vote']->findCount('vote_comment',array(
					'voteid'=>$voteid,
		));
		$new['vote']->update('vote',array(
				'voteid'=>$voteid,				
		),array(
				'count_comment'=>$count_comment,									
		));
		
		header("Location: ".tsUrl('vote','show',array('id'=>$voteid)));
	
		break;
		
	case "delete":
	
		$userid = aac('user')->isLogin();
	
		$commentid = intval($_GET['commentid']);
		$voteid = intval($_GET['voteid']);
	
		
		$new['vote']->delete('vote_comment',array(
				'commentid'=>$commentid,
				'userid'=>$userid,
		));
		//跳转回到话题页
		header("Location: ".tsUrl('vote','show',array('id'=>$voteid)));
	
		break;
	
}